{extend name="web/public/base" /}
{block name="header"}
{/block}
{block name="main"}
<section class="scrollable padder">
    <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
        <li><a><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">日结奖金</li>
        <li class="active">{$title}</li>
    </ul>
    <div class="row">
        <div class="col-sm-12">
            <section class="panel panel-default">
                <header class="panel-heading"> {$title}</header>
                <div class="table-responsive">
                    <span style="margin-left:15px;">当月业绩：<input type="text" id="achieve" value="{$achievement}"></span>
                    <span>超级管理员登录密码：</span><input type="password" name="password" id="password">
                    <a class="btn btn-link" href="#" onclick="fajiang1();return false;">点击月分红</a>
                    <a class="btn btn-link" href="#" onclick="fajiang2();return false;">点击发放月分红</a>
                </div>
            </section>
        </div>
    </div>
</section>
{/block}
{block name="script"}
<script type="text/javascript">
    function fajiang1() {
        var url = "{:url('User/dayBonus')}";
        var psd = $('#password').val();
        var achieve = $('#achieve').val();
        if (!psd) {
            layer.msg('请输入超级管理员登录密码！');
            return false;
        }
        var index = layer.load('正在发奖，请耐心等待');
        $.post(url, {type: 1, password: psd, achievement: achieve}, function (data) {
            layer.close(index);
            layer.msg(data.msg);
            setTimeout(function () {
                location.reload();
            }, 1000)
        }, "json");
        return false;
    }

    function fajiang2() {
        var url = "{:url('User/dayBonus')}";
        var psd = $('#password').val();
        if (!psd) {
            layer.msg('请输入超级管理员登录密码！');
            return false;
        }
        var index = layer.load('正在发奖，请耐心等待');
        $.post(url, {type: 2, password: psd}, function (data) {
            layer.close(index);
            layer.msg(data.msg);
            setTimeout(function () {
                location.reload();
            }, 1000)
        }, "json");
        return false;
    }

    $('#achieve').change(function () {
        var achievement = $(this).val();
        $.post("{:url('changeAchieve')}", {achievement: achievement}, function (data) {
            layer.msg(data.msg);
            setTimeout(function () {
                location.reload();
            }, 1000)
        }, "json");
    })
</script>
{/block}
{block name="footer"}
{/block}